<template>
  <div style="padding-left:15px;">
    <div>
      <!--表格渲染-->
      <el-table ref="mainTable" class="tl-table" v-loading="loading" :data="datas" style="width: 100%;" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName" :default-sort="{ prop: 'code', order: 'ascending' }">
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="name" label="名称" width="300px" sortable="custom" sort-by="name" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="version" label="文件最新版本号" width="250px" sortable="custom" sort-by="version" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="lastupdatetime" label="文件最后更新时间" sortable="custom" sort-by="lastupdatetime" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="操作" width="100px" v-slot="scope" fixed="right">
          <el-button type="text" icon="el-icon-document" @click="openIframeDialog('fileIframe', scope.row.url)">查看文件</el-button>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
    </div>
    <file-iframe ref="fileIframe" @refresh="doRefresh"></file-iframe>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from "@tapui/mixins/mixin_list"
import { mixin_approval } from "@tapui/mixins/mixin_approval"
/** 子组件 */
import fileIframe from "./iframe"
import { validateNull } from "@tapui/utils/validate"
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from "@tapui/utils/http"
export default {
  name: "flowFile",
  mixins: [mixin_list],
  components: { fileIframe },
  data() {
    return {
      description: "流程文件列表",
      urlPrefix: "/base/flowFile/",
      url: {
        // queryCodeList: '/base/flowFile/dataCodeList'
        queryLlowFileList: "/base/flowFile/list",
        queryLlowFileInsList: "/base/flowFileIns/list",
        loadFile: "/base/flowFile/loadFile"
      },
      // 排序参数
      sorterInfo: {
        sidx: "sortcode",
        sord: "asc"
      },
      filtersInfo: {
        flow_id: this.flowid,
        node_id: this.nodeid,
        flow_inst_id: this.flowinsid,
        node_inst_id: this.nodeinsid
      }
    }
  },
  props: {
    flowid: {
      default: 0,
      type: Number
    },
    nodeid: {
      default: 0,
      type: Number
    },
    flowinsid: {
      default: 0,
      type: Number
    },
    nodeinsid: {
      default: 0,
      type: Number
    },
    disableEditSubmit: {
      default: false,
      type: Boolean
    }
  },
  methods: {
    beforeLoadData() {
      if (!this.disableEditSubmit) {
        this.url.list = this.url.queryLlowFileList
      } else {
        this.url.list = this.url.queryLlowFileInsList
      }
      return true
    },
    openIframeDialog(fileIframe, url) {
      this.$refs.fileIframe.visible = true
      this.$refs.fileIframe.fileUrl = url
    }
  }
}
</script>

<style scoped></style>
